import { ColumnsType } from "antd/es/table"

import { handleNumber, handleNumberColor } from "@/utils/util"

export const NO_OUT_BILL_LIST_COLUMNS = "noOutBillList_"

const useColumns = (newFormat: Function, getLabel: Function) => {
	const columns: ColumnsType = [
		{
			title: newFormat("funds.fund_audit.bill_date"),
			dataIndex: "applyTime",
			key: "applyTime",
			align: "center",
			render: text => text || "-",
			width: 300
		},
		{
			title: newFormat("funds.fund_audit.snapshot_time"),
			dataIndex: "createTime",
			key: "createTime",
			align: "center",
			render: text => text || "-",
			width: 170
		},
		{
			title: newFormat("funds.fund_audit.account_number"),
			dataIndex: "acctName",
			key: "acctName",
			align: "center",
			render: text => text || "-",
			width: 180
		},
		{
			title: newFormat("funds.fund_audit.proxy_level_name"),
			dataIndex: "acctType",
			key: "acctType",
			align: "center",
			render: (text, record: any) =>
				record.acctType === 99
					? getLabel(record.acctType, "proxyLevelList", false)
					: record.acctType === 0
					? "0"
					: record.acctType || "-",
			width: 120
		},
		{
			title: newFormat("common.belong_merchant"),
			dataIndex: "topMerchantName",
			key: "topMerchantName",
			align: "center",
			render: text => text || "-",
			width: 180
		},
		{
			title: newFormat("common.top_agent"),
			dataIndex: "parentProxyName",
			key: "parentProxyName",
			align: "center",
			render: text => text || "-",
			width: 190
		},
		{
			title: newFormat("funds.fund_audit.belong_general_agent"),
			dataIndex: "topProxyName",
			key: "topProxyName",
			align: "center",
			render: text => text || "-",
			width: 190
		},
		{
			title: newFormat("funds.wind_control_level"),
			dataIndex: "windControlName",
			key: "windControlName",
			align: "center",
			render: text => text || "-",
			width: 130
		},
		{
			title: newFormat("funds.proxy_member_funds_record.account_status"),
			dataIndex: "acctStatus",
			key: "acctStatus",
			align: "center",
			render: (text: number) =>
				text === 1 ? (
					<span className="disableRgba">{newFormat("common.login_lock_status")}</span>
				) : text === 0 ? (
					<span className="normalRgba">{newFormat("common.account_status_normal")}</span>
				) : (
					""
				),
			width: 130
		},
		{
			title: newFormat("funds.settlement_bill_management.team_assets"),
			dataIndex: "teamFunds",
			key: "teamFunds",
			align: "center",
			render: (text, record: any) => (
				<span style={{ color: handleNumberColor(record.teamFunds) }}>{handleNumber(record.currency, record.teamFunds)}</span>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.team_payable_loan"),
			dataIndex: "teamReturnLoan",
			key: "teamReturnLoan",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.teamReturnLoan)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.team_withdrawable_limit"),
			dataIndex: "teamWithdrawable",
			key: "teamWithdrawable",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.teamWithdrawable)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.texas_club_service_charge_team_rebate"),
			dataIndex: "clubRebateAmount",
			key: "clubRebateAmount",
			align: "center",
			render: (text, record: any) => (
				<span style={{ color: handleNumberColor(record.clubRebateAmount) }}>
					{handleNumber(record.currency, record.clubRebateAmount)}
				</span>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.texas_insurance_team_share"),
			dataIndex: "insuranceRebateAmount",
			key: "insuranceRebateAmount",
			align: "center",
			render: (text, record: any) => (
				<span style={{ color: handleNumberColor(record.insuranceRebateAmount) }}>
					{handleNumber(record.currency, record.insuranceRebateAmount)}
				</span>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.texas_insurance_added"),
			dataIndex: "valueAddedTotalAmount",
			key: "valueAddedTotalAmount",
			align: "center",
			render: (text, record: any) => (
				<span style={{ color: handleNumberColor(record.valueAddedTotalAmount) }}>
					{handleNumber(record.currency, record.valueAddedTotalAmount)}
				</span>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.general_rebate"),
			dataIndex: "multipleRebateAmount",
			key: "multipleRebateAmount",
			align: "center",
			render: (text, record: any) => (
				<span style={{ color: handleNumberColor(record.multipleRebateAmount) }}>
					{handleNumber(record.currency, record.multipleRebateAmount)}
				</span>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.rebate_income"),
			dataIndex: "teamIncomeAmount",
			key: "teamIncomeAmount",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.teamIncomeAmount)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.general_divide"),
			dataIndex: "multipleRebateAmountRate",
			key: "multipleRebateAmountRate",
			align: "center",
			render: (text, record: any) => (
				<>
					{text === 0 || !text ? (
						"-"
					) : (
						<span style={{ color: handleNumberColor(text) }}>{handleNumber(record.currency, text)}</span>
					)}
				</>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.general_share"),
			dataIndex: "teamRebateSharing",
			key: "teamRebateSharing",
			align: "center",
			render: (text, record: any) => (
				<span style={{ color: handleNumberColor(text) }}>{handleNumber(record.currency, text)}</span>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.bill_net_assets"),
			dataIndex: "netAssets",
			key: "netAssets",
			align: "center",
			render: (text, record: any) => (
				<span style={{ color: handleNumberColor(record.netAssets) }}>{handleNumber(record.currency, record.netAssets)}</span>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.payable_bill_loan"),
			dataIndex: "returnLoan",
			key: "returnLoan",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.returnLoan)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.withdrawable_limit"),
			dataIndex: "withdrawable",
			key: "withdrawable",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.withdrawable)}</span>,
			width: 200
		},
		{
			title: newFormat("report.center_wallet_balance"),
			dataIndex: "walletBalance",
			key: "walletBalance",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.walletBalance)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.credit_wallet_balance"),
			dataIndex: "creditBalance",
			key: "creditBalance",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.creditBalance)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.should_repay"),
			dataIndex: "shouldRepay",
			key: "shouldRepay",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.shouldRepay)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.outside_amount"),
			dataIndex: "outsideAmount",
			key: "outsideAmount",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.outsideAmount)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.total_credit_amount"),
			dataIndex: "totalCreditAmount",
			key: "totalCreditAmount",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.totalCreditAmount)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.fund_audit.credit_limit"),
			dataIndex: "creditQuota",
			key: "creditQuota",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.creditQuota)}</span>,
			width: 200
		},
		// {
		// 	title: newFormat("funds.settlement_bill_management.person_rebate_amount"),
		// 	dataIndex: "personRebateAmount",
		// 	key: "personRebateAmount",
		// 	align: "center",
		// 	render: (text, record: any) => (
		// 		<span style={{ color: handleNumberColor(record.personRebateAmount) }}>
		// 			{handleNumber(record.currency, record.personRebateAmount)}
		// 		</span>
		// 	),
		// 	width: 200
		// },
		{
			title: newFormat("funds.settlement_bill_management.person_rebate_income"),
			dataIndex: "agencyPersonalIncome",
			key: "agencyPersonalIncome",
			align: "center",
			render: (text, record: any) => (
				<span style={{ color: handleNumberColor(record.agencyPersonalIncome) }}>
					{handleNumber(record.currency, record.agencyPersonalIncome)}
				</span>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.bet_amount"),
			dataIndex: "validBetAmount",
			key: "validBetAmount",
			align: "center",
			render: (text, record: any) => (
				<span style={{ color: handleNumberColor(record.validBetAmount) }}>
					{handleNumber(record.currency, record.validBetAmount)}
				</span>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.bet_count"),
			dataIndex: "betCount",
			key: "betCount",
			align: "center",
			render: text => handleNumber("", text, 0),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.net_amount"),
			dataIndex: "netAmount",
			key: "netAmount",
			align: "center",
			render: (text, record: any) => (
				<span style={{ color: handleNumberColor(record.netAmount) }}>{handleNumber(record.currency, record.netAmount)}</span>
			),
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.member_rebate_amount"),
			dataIndex: "memberRebateAmount",
			key: "memberRebateAmount",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.memberRebateAmount)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.member_deposit_amount"),
			dataIndex: "memberDepositAmount",
			key: "memberDepositAmount",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.memberDepositAmount)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.member_withdraw_amount"),
			dataIndex: "memberWithdrawAmount",
			key: "memberWithdrawAmount",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.memberWithdrawAmount)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.member_loan"),
			dataIndex: "memberLoan",
			key: "memberLoan",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.memberLoan)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.settlement_bill_management.member_repayment"),
			dataIndex: "memberRepayment",
			key: "memberRepayment",
			align: "center",
			render: (text, record: any) => <span>{handleNumber(record.currency, record.memberRepayment)}</span>,
			width: 200
		},
		{
			title: newFormat("funds.fund_audit.generation_time"),
			dataIndex: "generationTime",
			key: "generationTime",
			align: "center",
			render: (_text, record: any) => record.createTime || "-",
			width: 200
		}
	]

	const generatePrefixVariables = (columns: any) => {
		const prefixVariables: any = {}

		columns.forEach((column: any) => {
			const prefixName = `${NO_OUT_BILL_LIST_COLUMNS}${column.dataIndex}`

			prefixVariables[prefixName] = column
		})

		return prefixVariables
	}

	return generatePrefixVariables(columns)
}

export default useColumns
